package org.example.testdemo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.testdemo.pojo.Authorize;
import org.example.testdemo.pojo.combination.AuthorizeInformation;

@Mapper
public interface AuthorizeMapper extends BaseMapper<Authorize> {

    @Select("<script>" +
            "SELECT a.`authorizeId`,b.`name`,c.`p_name`,d.`b_Name` FROM `authorize` AS a,`user` AS b,`project` AS c,`department` AS d " +
            "WHERE a.`userId` = b.`userId` AND a.`p_id`=c.`p_id` AND a.`b_Code` = d.`b_Code` and c.p_id = #{projectId}" +
            "<if test='name != null'>" +
            "and b.name LIKE CONCAT('%', #{name}, '%') " +
            "</if>" +
            "</script>")
    public IPage<AuthorizeInformation> findByProjectId(@Param("name") String name, @Param("projectId") String projectId, Page<AuthorizeInformation> page);

}
